<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>打印三角形、平行四边形、菱形</title>
</head>
<body>

<script>
    //三角形
    for (var i = 1; i <= 5; i++) {
        for (var v = 1; v <= 5 - i; v++) {
            document.write("&nbsp;&nbsp;&nbsp;");
        }
        for (var j = 0; j < i; j++) {
            document.write('*' + "&nbsp;&nbsp;&nbsp;&nbsp;");
        }
        document.write('</br>');
    }
    //平行四边形
    for (var i = 1; i <= 5; i++) {
        for (var j = 1; j <= 5 - i; j++) {
            document.write("&nbsp;&nbsp;&nbsp;");
        }
        for (var k = 1; k <= 5; k++) {
            document.write("*" + "&nbsp;&nbsp;&nbsp;");
        }
        document.write("<br/>");
    }
    //菱形
    var n = 3;
    for (var i = 1; i <= 3; i++) {
        for (var k = 2; k >= i; k--) {
            document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
        }
        for (var j = 1; j <= 2 * i - 1; j++) {
            document.write("*" + "&nbsp;&nbsp;&nbsp;");
        }
        document.write("<br>");
    }
    for (var i = 1; i <= 2; i++) {
        for (var k = 1; k <= i; k++) {
            document.write("&nbsp;&nbsp;&nbsp;&nbsp;");
        }
        for (var j = 5; j >= 2 * i + 1; j--) {
            document.write("*" + "&nbsp;&nbsp;&nbsp;&nbsp;");
        }
        document.write("</br>");
    }
    document.write("</br>");

</script>
</body>
</html>